package com.funtonow.jqdk.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.CountDownTimer;

import com.funtonow.jqdk.ui.FloatingLayerActivity2;
import com.funtonow.jqdk.utils.ActivityManager;

import java.util.Objects;

/**
 * @author tkwy
 */
public class CountDownBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, Intent intent) {

        String currentActivity = ActivityManager.getInstance().getTopActivity().getLocalClassName();
        if (!Objects.equals(currentActivity, ".ui.UserInfoActivity")) {
            CountDownTimer countDownTimer = new CountDownTimer(120 * 1000, 1000) {
                @Override
                public void onTick(long millisUntilFinished) {
                    if (millisUntilFinished / 1000 == 0) {
                        context.startActivity(new Intent(context, FloatingLayerActivity2.class));
                    }
                }

                @Override
                public void onFinish() {
                }
            }.start();
        }

    }
}
